package cn.zlp.user.config;

import cn.zlp.user.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 登录拦截器配置类
 * @program: pethome
 * @author: Mr.Zhang
 * @create: 2021-12-09 19:42
 **/
@Configuration // 声明当前类为配置类
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 实现增加拦截器方法
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).excludePathPatterns("/login/**")
                //注册：放行用户注册：/user/register/**
                .excludePathPatterns("/user/register/**")
                //注册：放行店铺入驻
                .excludePathPatterns("/shop/settlement")
                //放行文件上传接口
                .excludePathPatterns("/fastDfs")
                //放行验证码
                .excludePathPatterns("/verifycode/**")
                //放行swagger
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**")
                //放行notify,异步请求修改状态
                .excludePathPatterns("/notify");
    }
}
